<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>vmlelement.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_graphics_vmlelement.js.html">vmlelement.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2007 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>
<a name="line16"></a>/**
<a name="line17"></a> * @fileoverview Thin wrappers around the DOM element returned from
<a name="line18"></a> * the different draw methods of the graphics. This is the VML implementation.
<a name="line19"></a> * @author arv@google.com (Erik Arvidsson)
<a name="line20"></a> * @author yoah@google.com (Yoah Bar-David)
<a name="line21"></a> */
<a name="line22"></a>
<a name="line23"></a>goog.provide(&#39;goog.graphics.VmlEllipseElement&#39;);
<a name="line24"></a>goog.provide(&#39;goog.graphics.VmlGroupElement&#39;);
<a name="line25"></a>goog.provide(&#39;goog.graphics.VmlImageElement&#39;);
<a name="line26"></a>goog.provide(&#39;goog.graphics.VmlPathElement&#39;);
<a name="line27"></a>goog.provide(&#39;goog.graphics.VmlRectElement&#39;);
<a name="line28"></a>goog.provide(&#39;goog.graphics.VmlTextElement&#39;);
<a name="line29"></a>
<a name="line30"></a>
<a name="line31"></a>goog.require(&#39;goog.dom&#39;);
<a name="line32"></a>goog.require(&#39;goog.graphics.EllipseElement&#39;);
<a name="line33"></a>goog.require(&#39;goog.graphics.GroupElement&#39;);
<a name="line34"></a>goog.require(&#39;goog.graphics.ImageElement&#39;);
<a name="line35"></a>goog.require(&#39;goog.graphics.PathElement&#39;);
<a name="line36"></a>goog.require(&#39;goog.graphics.RectElement&#39;);
<a name="line37"></a>goog.require(&#39;goog.graphics.TextElement&#39;);
<a name="line38"></a>
<a name="line39"></a>
<a name="line40"></a>/**
<a name="line41"></a> * Returns the VML element corresponding to this object.  This method is added
<a name="line42"></a> * to several classes below.  Note that the return value of this method may
<a name="line43"></a> * change frequently in IE8, so it should not be cached externally.
<a name="line44"></a> * @return {Element} The VML element corresponding to this object.
<a name="line45"></a> * @this {goog.graphics.VmlGroupElement|goog.graphics.VmlEllipseElement|
<a name="line46"></a> *     goog.graphics.VmlRectElement|goog.graphics.VmlPathElement|
<a name="line47"></a> *     goog.graphics.VmlTextElement|goog.graphics.VmlImageElement}
<a name="line48"></a> * @private
<a name="line49"></a> */
<a name="line50"></a>goog.graphics.vmlGetElement_ = function() {
<a name="line51"></a>  this.element_ = this.getGraphics().getVmlElement(this.id_) || this.element_;
<a name="line52"></a>  return this.element_;
<a name="line53"></a>};
<a name="line54"></a>
<a name="line55"></a>
<a name="line56"></a>
<a name="line57"></a>/**
<a name="line58"></a> * Thin wrapper for VML group elements.
<a name="line59"></a> * This is an implementation of the goog.graphics.GroupElement interface.
<a name="line60"></a> * You should not construct objects from this constructor. The graphics
<a name="line61"></a> * will return the object for you.
<a name="line62"></a> * @param {Element} element The DOM element to wrap.
<a name="line63"></a> * @param {goog.graphics.VmlGraphics} graphics The graphics creating
<a name="line64"></a> *     this element.
<a name="line65"></a> * @constructor
<a name="line66"></a> * @extends {goog.graphics.GroupElement}
<a name="line67"></a> */
<a name="line68"></a>goog.graphics.VmlGroupElement = function(element, graphics) {
<a name="line69"></a>  this.id_ = element.id;
<a name="line70"></a>  goog.graphics.GroupElement.call(this, element, graphics);
<a name="line71"></a>};
<a name="line72"></a>goog.inherits(goog.graphics.VmlGroupElement, goog.graphics.GroupElement);
<a name="line73"></a>
<a name="line74"></a>
<a name="line75"></a>/** @override */
<a name="line76"></a>goog.graphics.VmlGroupElement.prototype.getElement =
<a name="line77"></a>    goog.graphics.vmlGetElement_;
<a name="line78"></a>
<a name="line79"></a>
<a name="line80"></a>/**
<a name="line81"></a> * Remove all drawing elements from the group.
<a name="line82"></a> * @override
<a name="line83"></a> */
<a name="line84"></a>goog.graphics.VmlGroupElement.prototype.clear = function() {
<a name="line85"></a>  goog.dom.removeChildren(this.getElement());
<a name="line86"></a>};
<a name="line87"></a>
<a name="line88"></a>
<a name="line89"></a>/**
<a name="line90"></a> * @return {boolean} True if this group is the root canvas element.
<a name="line91"></a> * @private
<a name="line92"></a> */
<a name="line93"></a>goog.graphics.VmlGroupElement.prototype.isRootElement_ = function() {
<a name="line94"></a>  return this.getGraphics().getCanvasElement() == this;
<a name="line95"></a>};
<a name="line96"></a>
<a name="line97"></a>
<a name="line98"></a>/**
<a name="line99"></a> * Set the size of the group element.
<a name="line100"></a> * @param {number|string} width The width of the group element.
<a name="line101"></a> * @param {number|string} height The height of the group element.
<a name="line102"></a> * @override
<a name="line103"></a> */
<a name="line104"></a>goog.graphics.VmlGroupElement.prototype.setSize = function(width, height) {
<a name="line105"></a>  var element = this.getElement();
<a name="line106"></a>
<a name="line107"></a>  var style = element.style;
<a name="line108"></a>  style.width = goog.graphics.VmlGraphics.toSizePx(width);
<a name="line109"></a>  style.height = goog.graphics.VmlGraphics.toSizePx(height);
<a name="line110"></a>
<a name="line111"></a>  element.coordsize = goog.graphics.VmlGraphics.toSizeCoord(width) + &#39; &#39; +
<a name="line112"></a>      goog.graphics.VmlGraphics.toSizeCoord(height);
<a name="line113"></a>
<a name="line114"></a>  // Don&#39;t overwrite the root element&#39;s origin.
<a name="line115"></a>  if (!this.isRootElement_()) {
<a name="line116"></a>    element.coordorigin = &#39;0 0&#39;;
<a name="line117"></a>  }
<a name="line118"></a>};
<a name="line119"></a>
<a name="line120"></a>
<a name="line121"></a>
<a name="line122"></a>/**
<a name="line123"></a> * Thin wrapper for VML ellipse elements.
<a name="line124"></a> * This is an implementation of the goog.graphics.EllipseElement interface.
<a name="line125"></a> * You should not construct objects from this constructor. The graphics
<a name="line126"></a> * will return the object for you.
<a name="line127"></a> * @param {Element} element The DOM element to wrap.
<a name="line128"></a> * @param {goog.graphics.VmlGraphics} graphics  The graphics creating
<a name="line129"></a> *     this element.
<a name="line130"></a> * @param {number} cx Center X coordinate.
<a name="line131"></a> * @param {number} cy Center Y coordinate.
<a name="line132"></a> * @param {number} rx Radius length for the x-axis.
<a name="line133"></a> * @param {number} ry Radius length for the y-axis.
<a name="line134"></a> * @param {goog.graphics.Stroke?} stroke The stroke to use for this element.
<a name="line135"></a> * @param {goog.graphics.Fill?} fill The fill to use for this element.
<a name="line136"></a> * @constructor
<a name="line137"></a> * @extends {goog.graphics.EllipseElement}
<a name="line138"></a> */
<a name="line139"></a>goog.graphics.VmlEllipseElement = function(element, graphics,
<a name="line140"></a>    cx, cy, rx, ry, stroke, fill) {
<a name="line141"></a>  this.id_ = element.id;
<a name="line142"></a>
<a name="line143"></a>  goog.graphics.EllipseElement.call(this, element, graphics, stroke, fill);
<a name="line144"></a>
<a name="line145"></a>  // Store center and radius for future calls to setRadius or setCenter.
<a name="line146"></a>
<a name="line147"></a>  /**
<a name="line148"></a>   * X coordinate of the ellipse center.
<a name="line149"></a>   * @type {number}
<a name="line150"></a>   */
<a name="line151"></a>  this.cx = cx;
<a name="line152"></a>
<a name="line153"></a>
<a name="line154"></a>  /**
<a name="line155"></a>   * Y coordinate of the ellipse center.
<a name="line156"></a>   * @type {number}
<a name="line157"></a>   */
<a name="line158"></a>  this.cy = cy;
<a name="line159"></a>
<a name="line160"></a>
<a name="line161"></a>  /**
<a name="line162"></a>   * Radius length for the x-axis.
<a name="line163"></a>   * @type {number}
<a name="line164"></a>   */
<a name="line165"></a>  this.rx = rx;
<a name="line166"></a>
<a name="line167"></a>
<a name="line168"></a>  /**
<a name="line169"></a>   * Radius length for the y-axis.
<a name="line170"></a>   * @type {number}
<a name="line171"></a>   */
<a name="line172"></a>  this.ry = ry;
<a name="line173"></a>};
<a name="line174"></a>goog.inherits(goog.graphics.VmlEllipseElement, goog.graphics.EllipseElement);
<a name="line175"></a>
<a name="line176"></a>
<a name="line177"></a>/** @override */
<a name="line178"></a>goog.graphics.VmlEllipseElement.prototype.getElement =
<a name="line179"></a>    goog.graphics.vmlGetElement_;
<a name="line180"></a>
<a name="line181"></a>
<a name="line182"></a>/**
<a name="line183"></a> * Update the center point of the ellipse.
<a name="line184"></a> * @param {number} cx Center X coordinate.
<a name="line185"></a> * @param {number} cy Center Y coordinate.
<a name="line186"></a> * @override
<a name="line187"></a> */
<a name="line188"></a>goog.graphics.VmlEllipseElement.prototype.setCenter = function(cx, cy) {
<a name="line189"></a>  this.cx = cx;
<a name="line190"></a>  this.cy = cy;
<a name="line191"></a>  goog.graphics.VmlGraphics.setPositionAndSize(this.getElement(),
<a name="line192"></a>      cx - this.rx, cy - this.ry, this.rx * 2, this.ry * 2);
<a name="line193"></a>};
<a name="line194"></a>
<a name="line195"></a>
<a name="line196"></a>/**
<a name="line197"></a> * Update the radius of the ellipse.
<a name="line198"></a> * @param {number} rx Center X coordinate.
<a name="line199"></a> * @param {number} ry Center Y coordinate.
<a name="line200"></a> * @override
<a name="line201"></a> */
<a name="line202"></a>goog.graphics.VmlEllipseElement.prototype.setRadius = function(rx, ry) {
<a name="line203"></a>  this.rx = rx;
<a name="line204"></a>  this.ry = ry;
<a name="line205"></a>  goog.graphics.VmlGraphics.setPositionAndSize(this.getElement(),
<a name="line206"></a>      this.cx - rx, this.cy - ry, rx * 2, ry * 2);
<a name="line207"></a>};
<a name="line208"></a>
<a name="line209"></a>
<a name="line210"></a>
<a name="line211"></a>/**
<a name="line212"></a> * Thin wrapper for VML rectangle elements.
<a name="line213"></a> * This is an implementation of the goog.graphics.RectElement interface.
<a name="line214"></a> * You should not construct objects from this constructor. The graphics
<a name="line215"></a> * will return the object for you.
<a name="line216"></a> * @param {Element} element The DOM element to wrap.
<a name="line217"></a> * @param {goog.graphics.VmlGraphics} graphics The graphics creating
<a name="line218"></a> *     this element.
<a name="line219"></a> * @param {goog.graphics.Stroke?} stroke The stroke to use for this element.
<a name="line220"></a> * @param {goog.graphics.Fill?} fill The fill to use for this element.
<a name="line221"></a> * @constructor
<a name="line222"></a> * @extends {goog.graphics.RectElement}
<a name="line223"></a> */
<a name="line224"></a>goog.graphics.VmlRectElement = function(element, graphics, stroke, fill) {
<a name="line225"></a>  this.id_ = element.id;
<a name="line226"></a>  goog.graphics.RectElement.call(this, element, graphics, stroke, fill);
<a name="line227"></a>};
<a name="line228"></a>goog.inherits(goog.graphics.VmlRectElement, goog.graphics.RectElement);
<a name="line229"></a>
<a name="line230"></a>
<a name="line231"></a>/** @override */
<a name="line232"></a>goog.graphics.VmlRectElement.prototype.getElement =
<a name="line233"></a>    goog.graphics.vmlGetElement_;
<a name="line234"></a>
<a name="line235"></a>
<a name="line236"></a>/**
<a name="line237"></a> * Update the position of the rectangle.
<a name="line238"></a> * @param {number} x X coordinate (left).
<a name="line239"></a> * @param {number} y Y coordinate (top).
<a name="line240"></a> * @override
<a name="line241"></a> */
<a name="line242"></a>goog.graphics.VmlRectElement.prototype.setPosition = function(x, y) {
<a name="line243"></a>  var style = this.getElement().style;
<a name="line244"></a>  style.left = goog.graphics.VmlGraphics.toPosPx(x);
<a name="line245"></a>  style.top = goog.graphics.VmlGraphics.toPosPx(y);
<a name="line246"></a>};
<a name="line247"></a>
<a name="line248"></a>
<a name="line249"></a>/**
<a name="line250"></a> * Update the size of the rectangle.
<a name="line251"></a> * @param {number} width Width of rectangle.
<a name="line252"></a> * @param {number} height Height of rectangle.
<a name="line253"></a> * @override
<a name="line254"></a> */
<a name="line255"></a>goog.graphics.VmlRectElement.prototype.setSize = function(width, height) {
<a name="line256"></a>  var style = this.getElement().style;
<a name="line257"></a>  style.width = goog.graphics.VmlGraphics.toSizePx(width);
<a name="line258"></a>  style.height = goog.graphics.VmlGraphics.toSizePx(height);
<a name="line259"></a>};
<a name="line260"></a>
<a name="line261"></a>
<a name="line262"></a>
<a name="line263"></a>/**
<a name="line264"></a> * Thin wrapper for VML path elements.
<a name="line265"></a> * This is an implementation of the goog.graphics.PathElement interface.
<a name="line266"></a> * You should not construct objects from this constructor. The graphics
<a name="line267"></a> * will return the object for you.
<a name="line268"></a> * @param {Element} element The DOM element to wrap.
<a name="line269"></a> * @param {goog.graphics.VmlGraphics} graphics The graphics creating
<a name="line270"></a> *     this element.
<a name="line271"></a> * @param {goog.graphics.Stroke?} stroke The stroke to use for this element.
<a name="line272"></a> * @param {goog.graphics.Fill?} fill The fill to use for this element.
<a name="line273"></a> * @constructor
<a name="line274"></a> * @extends {goog.graphics.PathElement}
<a name="line275"></a> */
<a name="line276"></a>goog.graphics.VmlPathElement = function(element, graphics, stroke, fill) {
<a name="line277"></a>  this.id_ = element.id;
<a name="line278"></a>  goog.graphics.PathElement.call(this, element, graphics, stroke, fill);
<a name="line279"></a>};
<a name="line280"></a>goog.inherits(goog.graphics.VmlPathElement, goog.graphics.PathElement);
<a name="line281"></a>
<a name="line282"></a>
<a name="line283"></a>/** @override */
<a name="line284"></a>goog.graphics.VmlPathElement.prototype.getElement =
<a name="line285"></a>    goog.graphics.vmlGetElement_;
<a name="line286"></a>
<a name="line287"></a>
<a name="line288"></a>/**
<a name="line289"></a> * Update the underlying path.
<a name="line290"></a> * @param {!goog.graphics.Path} path The path object to draw.
<a name="line291"></a> * @override
<a name="line292"></a> */
<a name="line293"></a>goog.graphics.VmlPathElement.prototype.setPath = function(path) {
<a name="line294"></a>  goog.graphics.VmlGraphics.setAttribute(
<a name="line295"></a>      this.getElement(), &#39;path&#39;, goog.graphics.VmlGraphics.getVmlPath(path));
<a name="line296"></a>};
<a name="line297"></a>
<a name="line298"></a>
<a name="line299"></a>
<a name="line300"></a>/**
<a name="line301"></a> * Thin wrapper for VML text elements.
<a name="line302"></a> * This is an implementation of the goog.graphics.TextElement interface.
<a name="line303"></a> * You should not construct objects from this constructor. The graphics
<a name="line304"></a> * will return the object for you.
<a name="line305"></a> * @param {Element} element The DOM element to wrap.
<a name="line306"></a> * @param {goog.graphics.VmlGraphics} graphics The graphics creating
<a name="line307"></a> *     this element.
<a name="line308"></a> * @param {goog.graphics.Stroke?} stroke The stroke to use for this element.
<a name="line309"></a> * @param {goog.graphics.Fill?} fill The fill to use for this element.
<a name="line310"></a> * @constructor
<a name="line311"></a> * @extends {goog.graphics.TextElement}
<a name="line312"></a> */
<a name="line313"></a>goog.graphics.VmlTextElement = function(element, graphics, stroke, fill) {
<a name="line314"></a>  this.id_ = element.id;
<a name="line315"></a>  goog.graphics.TextElement.call(this, element, graphics, stroke, fill);
<a name="line316"></a>};
<a name="line317"></a>goog.inherits(goog.graphics.VmlTextElement, goog.graphics.TextElement);
<a name="line318"></a>
<a name="line319"></a>
<a name="line320"></a>/** @override */
<a name="line321"></a>goog.graphics.VmlTextElement.prototype.getElement =
<a name="line322"></a>    goog.graphics.vmlGetElement_;
<a name="line323"></a>
<a name="line324"></a>
<a name="line325"></a>/**
<a name="line326"></a> * Update the displayed text of the element.
<a name="line327"></a> * @param {string} text The text to draw.
<a name="line328"></a> * @override
<a name="line329"></a> */
<a name="line330"></a>goog.graphics.VmlTextElement.prototype.setText = function(text) {
<a name="line331"></a>  goog.graphics.VmlGraphics.setAttribute(this.getElement().childNodes[1],
<a name="line332"></a>      &#39;string&#39;, text);
<a name="line333"></a>};
<a name="line334"></a>
<a name="line335"></a>
<a name="line336"></a>
<a name="line337"></a>/**
<a name="line338"></a> * Thin wrapper for VML image elements.
<a name="line339"></a> * This is an implementation of the goog.graphics.ImageElement interface.
<a name="line340"></a> * You should not construct objects from this constructor. The graphics
<a name="line341"></a> * will return the object for you.
<a name="line342"></a> * @param {Element} element The DOM element to wrap.
<a name="line343"></a> * @param {goog.graphics.VmlGraphics} graphics The graphics creating
<a name="line344"></a> *     this element.
<a name="line345"></a> * @constructor
<a name="line346"></a> * @extends {goog.graphics.ImageElement}
<a name="line347"></a> */
<a name="line348"></a>goog.graphics.VmlImageElement = function(element, graphics) {
<a name="line349"></a>  this.id_ = element.id;
<a name="line350"></a>  goog.graphics.ImageElement.call(this, element, graphics);
<a name="line351"></a>};
<a name="line352"></a>goog.inherits(goog.graphics.VmlImageElement, goog.graphics.ImageElement);
<a name="line353"></a>
<a name="line354"></a>
<a name="line355"></a>/** @override */
<a name="line356"></a>goog.graphics.VmlImageElement.prototype.getElement =
<a name="line357"></a>    goog.graphics.vmlGetElement_;
<a name="line358"></a>
<a name="line359"></a>
<a name="line360"></a>/**
<a name="line361"></a> * Update the position of the image.
<a name="line362"></a> * @param {number} x X coordinate (left).
<a name="line363"></a> * @param {number} y Y coordinate (top).
<a name="line364"></a> * @override
<a name="line365"></a> */
<a name="line366"></a>goog.graphics.VmlImageElement.prototype.setPosition = function(x, y) {
<a name="line367"></a>  var style = this.getElement().style;
<a name="line368"></a>  style.left = goog.graphics.VmlGraphics.toPosPx(x);
<a name="line369"></a>  style.top = goog.graphics.VmlGraphics.toPosPx(y);
<a name="line370"></a>};
<a name="line371"></a>
<a name="line372"></a>
<a name="line373"></a>/**
<a name="line374"></a> * Update the size of the image.
<a name="line375"></a> * @param {number} width Width of rectangle.
<a name="line376"></a> * @param {number} height Height of rectangle.
<a name="line377"></a> * @override
<a name="line378"></a> */
<a name="line379"></a>goog.graphics.VmlImageElement.prototype.setSize = function(width, height) {
<a name="line380"></a>  var style = this.getElement().style;
<a name="line381"></a>  style.width = goog.graphics.VmlGraphics.toPosPx(width);
<a name="line382"></a>  style.height = goog.graphics.VmlGraphics.toPosPx(height);
<a name="line383"></a>};
<a name="line384"></a>
<a name="line385"></a>
<a name="line386"></a>/**
<a name="line387"></a> * Update the source of the image.
<a name="line388"></a> * @param {string} src Source of the image.
<a name="line389"></a> * @override
<a name="line390"></a> */
<a name="line391"></a>goog.graphics.VmlImageElement.prototype.setSource = function(src) {
<a name="line392"></a>  goog.graphics.VmlGraphics.setAttribute(this.getElement(), &#39;src&#39;, src);
<a name="line393"></a>};
</pre>


</body>
</html>
